%---------------------------------------------------------------------------
%Please be aware that the use of this LaTeX class file is governed by the
%following conditions:
%
% based on the original LaTeX ARTICLE DOCUMENT STYLE
% Copyright (C) 1988, 1989 by Leslie Lamport
%
% Copyright (c) 
%---------------------------------------------------------------------------
%
% Created by E

\def\update{2022/03/18 v0.0.1}

\newcommand{\journalclass}{cjeart.cls}
\newcommand{\journalclassshort}{cjeart}
%\newcommand{\DOI}[1][xxxxxx/xxxx-xxx-xxx-xxxx]{#1}
\def\volumeyear#1{\gdef\@volumeyear{#1}}\def\@volumeyear{2022}
\def\volumenumber#1{\gdef\@volumenumber{#1}}\def\@volumenumber{1}
\def\issuenumber#1{\gdef\@issuenumber{#1}}\def\@issuenumber{1}
\def\journalname#1{\gdef\@journalname{#1}}\def\@journalname{Chinese Journal of Electronics}
\def\journaltype#1{\gdef\@journaltype{#1}}\def\@journaltype{Original ariticle}
\def\DOI#1{\gdef\@DOI{#1}}\def\@DOI{xxxxxx/xxxx-xxx-xxx-xxxx}
\def\title[#1]#2{\gdef\@shorttitle{#1} \def\@title{#2}}\def\@shorttitle1{\@title}

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{emsart}[\update\ \journalclass]

%\newcommand\hmmax{0}

\newif\if@timesfont
\DeclareOption{times}{%
\@timesfonttrue}

\newif\if@doublespace
\DeclareOption{doublespace}{%
\@doublespacetrue}


\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
\LoadClass{article}

%\RequirePackage[T1]{fontenc}
%\usepackage{libertine}

\if@timesfont
\RequirePackage{times}
\usepackage[scaled=.95]{helvet}
\fi
%\if@doublespace
%\RequirePackage[onehalfspacing]{setspace}
%\fi
%\RequirePackage{setspace}

\RequirePackage{graphicx}
\graphicspath{{figures/}}

%\RequirePackage{latexsym,ifthen,rotating,calc,textcase,booktabs,color,endnotes}
\RequirePackage{endnotes}
\RequirePackage{xcolor}
\RequirePackage{amsfonts,amssymb}%amsbsy,
\RequirePackage{amsmath,amsthm}
%\RequirePackage{bm}
%\RequirePackage[errorshow]{tracefnt}
\RequirePackage{url}

\RequirePackage{float}
\newfloat{onefootnote}{hb}
%\renewcommand{\footnote}[1]{%
%    \begin{onefootnote*}[hb!]
%        #1
%    \end{onefootnote*}
%}

\definecolor{blueO}{RGB}{47,84,151}
\definecolor{titleblue}{RGB}{56,80,135}
\definecolor{titleblueI}{RGB}{108,146,204}
\definecolor{titleblueII}{RGB}{158,196,232}

\newcommand{\Bjournaltype}{%\emsartsf%\bfseries%\scshape
    \textcolor{blueO}{\@journaltype}}
\let\old@rule\@rule
\def\@rule[#1]#2#3{\textcolor{blueO}{\old@rule[#1]{#2}{#3}}}

\@twosidetrue
\flushbottom
\frenchspacing

\let\emsartsf\sf

%papersize={width,height}

\RequirePackage[text={175.5mm,226mm},%
papersize={210mm,280mm},%
columnsep=12pt,%
headsep=10pt,%
centering]{geometry}
%\usepackage{ftnright}

%\parindent 2em

\iffalse
\hyphenpenalty=1000
\pretolerance=8000
\tolerance=9500
\hbadness=8000
\vbadness=9000
\displaywidowpenalty=0
\clubpenalty=10000
\widowpenalty=10000
\lefthyphenmin=3%
\righthyphenmin=3%
\brokenpenalty=10000%

\thinmuskip = 3mu
\medmuskip = 4mu
\thickmuskip = 5mu
%\fi

\setcounter{topnumber}{10}
\def\topfraction{1}
\setcounter{bottomnumber}{10}
\def\bottomfraction{0.8}
\setcounter{totalnumber}{10}
\def\textfraction{0}
\renewcommand{\floatpagefraction}{0.95}
\setcounter{dbltopnumber}{10}
\renewcommand{\dblfloatpagefraction}{0.95}
\renewcommand{\dbltopfraction}{1}

\renewcommand\small{%
   \@setfontsize\small\@ixpt{10.5}%
   \abovedisplayskip 8.5\p@ \@plus3\p@ \@minus4\p@
   \abovedisplayshortskip \z@ \@plus2\p@
   \belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@
   \def\@listi{\leftmargin\leftmargini
               \topsep 4\p@ \@plus2\p@ \@minus2\p@
               %\parsep 2\p@ \@plus\p@ \@minus\p@
               \itemsep \parsep}%
   \belowdisplayskip \abovedisplayskip
}
\fi

%% font size define
\newcommand{\refsize}{\fontsize{8bp}{9.6bp}\selectfont}
\renewcommand{\footnotesize}{\fontsize{8bp}{9.6bp}\selectfont}
\renewcommand{\scriptsize}{\fontsize{7.0}{8.5pt}\selectfont}
\renewcommand{\large}{\fontsize{12}{14pt}\selectfont}
\newcommand{\titlesize}{\fontsize{21bp}{25.2bp}\selectfont}

\newcommand{\eightbp}{\fontsize{8bp}{9.6bp}\selectfont}
\newcommand{\ninebp}{\fontsize{9bp}{10.8bp}\selectfont}
\newcommand{\tenbp}{\fontsize{10bp}{12bp}\selectfont}
\newcommand{\elevenbp}{\fontsize{11bp}{13.2bp}\selectfont}
\newcommand{\twelvebp}{\fontsize{12bp}{14.4bp}\selectfont}

%\skip\footins 20pt plus  8pt
%\gdef\footnoterule{}
\def\footnoterule{\kern-3\p@
  \hrule \@width \columnwidth \kern 3mm}

\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\long\def\@makefntext#1{%%\parindent 1em%
\noindent{$\m@th^{\@thefnmark}$}#1}

\newcommand{\email}[1]{%
  \gdef\@email{%
    %\footnotetext[0]
      {Email: #1}}}
\let\@email\@empty

\def\corrauth#1{\gdef\@corrauth{%
    %\footnotetext[0]
    {\noindent{Corresponding author:} #1}}}
\let\@corrauth\@empty

\def\receivetime#1{\gdef\@receivetime{#1}}\let\@receivetime\@empty
\def\accepttime#1{\gdef\@accepttime{#1}}\let\@accepttime\@empty
\def\publishtime#1{\gdef\@publishtime{#1}}\let\@publishtime\@empty
\def\fundinginfo#1{\gdef\@fundinginfo{#1}}\let\@fundinginfo\@empty
\def\authorcopy#1{\gdef\@authorcopy{#1}}\let\@authorcopy\@empty

\def\affiliation#1{\gdef\@affiliation{\textit{#1 }}}
\let\@affiliation\@empty

\def\affilnums#1{${}^{\text{{#1}}}$}
\def\affilnum#1{{\rm #1}.~}

\renewcommand\maketitle{\par
  \begingroup
     \if@twocolumn
      \ifnum \col@number=\@ne
        \@maketitle
      \else
        \twocolumn[\@maketitle]%
       \fi
    \else
      \newpage
      \global\@topnum\z@   % Prevents figures from going at top of page.
      \@maketitle
    \fi
    %\@corrauth\@email \@paperinfo%
  \endgroup
  \global\let\affiliation\relax
  \global\let\thanks\relax
  \global\let\maketitle\relax
  \global\let\@maketitle\relax
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  %\global\let\@title\@empty
  \global\let\@affiliation\@empty
  \global\let\title\relax
  \global\let\author\relax
  \global\let\date\relax
  \global\let\and\relax
}

%% abstract
\def\abstract#1{%
    \gdef\@abstract{\eightbp\emsartsf%
    \noindent\textbf{Abstract}\,---\,#1}
}
\def\@abstract{\eightbp\emsartsf%
    \noindent\textbf{Abstract}\,---\,}

%% keywords
\def\keywords#1{%
    \gdef\@keywords{\eightbp\emsartsf%
        \noindent\textbf{Keywords}\,---\,#1}
}
\def\@keywords{\eightbp\emsartsf%
    \noindent\textbf{Keywords} -- ~ }

%% abstract
\def\@maketitle{%
  \thispagestyle{title}\label{FirstPage}
  \vspace*{-34pt}%
  \null%
  \parbox[b]{0.3\textwidth}{%
    \ninebp
    \@journalname\par
    vol.\@volumenumber, %
    no.\@issuenumber, %
    pp.\@startpage--\,\@endpage, %
    \@volumeyear
    \par
    {https://doi.org/\@DOI}
  }\hfill
  \parbox[b]{0.6\textwidth}{\flushright%
    \includegraphics[width=0.11\linewidth]{cje-logo}
    %\flushright\titlesize\bfseries\scshape%
    %\textcolor{blueO}{\@journalname}
  }\par
  \vspace{4em}
  {%\emsartsf
      \Large \Bjournaltype} \par
  \vspace{1.2em}
  %\begin{sf}
    {\raggedright\titlesize\textbf{\@title} \par}
    \vspace{3.2em}%
    {\raggedright\twelvebp{\@author} \par}
    \vspace{1.6em}
    {\raggedright\ninebp{\@affiliation} \par}
  %\end{sf}
  \vspace{0.8em}\par%
  {\eightbp
  \@corrauth; \@email.\par
  \@receivetime; \@accepttime; \@publishtime. %
  \@fundinginfo \par
  }
  \vspace{0.8em}
  \@abstract \par
  \@keywords
  \vspace{2em}
}

%% head foot
\def\startpage#1{\gdef\@startpage{#1}}\def\@startpage{\pageref{FirstPage}}
\def\endpage#1{\gdef\@endpage{#1}}\def\@endpage{\pageref{LastPage}}

%% head foot
\RequirePackage{tikz}

\newcommand{\oldedgetitle}[3]{%
    \begin{tikzpicture}[remember picture,overlay]
        \shade [top color=titleblueI, %
            bottom color=titleblue, %
            draw=titleblueI, 
            line width=0pt] 
            ([yshift=-0.3\paperheight]current page.#1) %
            rectangle
            ([yshift=-0.5\paperheight,xshift=#2]current page.#1);
        \shade [top color=titleblueII, %
            bottom color=titleblueI, %
            draw=titleblueI, 
            line width=0pt] 
            ([yshift=-0.1\paperheight]current page.#1) %
            rectangle
            ([yshift=-0.3\paperheight,xshift=#2]current page.#1);
        \shade [top color=white, %
            bottom color=titleblueII, %
            line width=0pt] 
            ([yshift=0.1\paperheight]current page.#1) %
            rectangle
            ([yshift=-0.101\paperheight,xshift=#2]current page.#1);
        \node[rotate=90, color=white, anchor=west] %
            at ([xshift=#3, yshift=-0.49\paperheight]current page.#1) %
            {\titlesize\bfseries\scshape \@journalname};
    \end{tikzpicture}%
}

\newcommand{\edgetitle}[4]{%
    \begin{tikzpicture}[remember picture, overlay]
        \node[anchor=#2] at %
        ([xshift=#4]current page.#1) %
        {\includegraphics[height=\paperheight]{cje-vert-#3}};
    \end{tikzpicture}
}

\newcommand{\oddedgetitle}{\edgetitle{west}{west}{left}{-3mm}}
\newcommand{\evenedgetitle}{\edgetitle{east}{east}{right}{3mm}}

\def\runninghead#1{\markboth{{#1}}{}}

\def\ps@title{%
  \def\@oddhead{\parbox{\textwidth}{\mbox{}\\[-1pt]%
  \noindent\rule{\textwidth}{0pt}%
  } \oddedgetitle }%
  \let\@evenhead\@oddhead
  \def\@oddfoot{\centering\parbox[t]{\textwidth}{%
    %{~\hfill\small ~\thepage~ \hfill ~}
    }}
\let\@evenfoot\@oddfoot}

\def\ps@emsartpage{%
  \let\@mkboth\@gobbletwo
  \def\@evenhead{\parbox{\textwidth}{%\emsartsf%
      {\ninebp\@shorttitle} \hfill ~{\ninebp\thepage}~ \\[-8pt]
    \noindent\rule{\textwidth}{0.3pt}}%
    \evenedgetitle }
  \def\@oddhead{\parbox{\textwidth}{%\emsartsf%
      ~{\ninebp\thepage}~ \hfill {\ninebp%
         \@journalname, %
         vol.\@volumenumber, %
         no.\@issuenumber, %
         pp.\@startpage-\@endpage, %
         \volumeyear, %\par
         https://doi.org/\@DOI}
        %\@shorttitle} 
        \\[-8pt]
    \noindent\rule{\textwidth}{0.3pt}}%
    \oddedgetitle }
  \def\@evenfoot{\parbox[t]{\textwidth}{%
    %{~\hfill\small ~\thepage~ \hfill ~}
    }}
  \def\@oddfoot{\@evenfoot}
}

%\newdimen\@bls                              
%\@bls=\baselineskip

\RequirePackage{titlesec}
\titleformat{\section}[hang]{\elevenbp\bfseries}{\Roman{section}.}{0.5em}{}
\titleformat{\subsection}[hang]{\tenbp\bfseries}{\arabic{subsection}.}{0.5em}{}
\titleformat{\subsubsection}[hang]{\tenbp}{\arabic{subsubsection})}{0.5em}{}

\titlespacing{\section}{0pt}{0.5em}{0.5em}[0pt]
\titlespacing{\subsection}{0pt}{0.5em}{0em}[0pt]
\titlespacing{\subsubsection}{0pt}{0em}{0em}[0pt]

%% section/equation tag in appendix
\renewcommand{\appendix}{%
    \setcounter{section}{0}
    \titleformat{\section}[hang]{\tenbp\bfseries}{Appendix \Alph{section}.}{0.5em}{}
  \titleformat{\subsection}[hang]{\eightbp\bfseries}{\arabic{subsection}.}{0.5em}{}
    \titleformat{\subsubsection}[hang]{\eightbp}{\arabic{subsubsection})}{0.5em}{}
    \setcounter{equation}{0}
    \numberwithin{equation}{section}
    \renewcommand{\theequation}{\Alph{section}-\arabic{equation}}
    \setcounter{figure}{0}
    \numberwithin{figure}{section}
    \renewcommand{\thefigure}{\Alph{section}-\arabic{figure}}
    \setcounter{table}{0}
    \numberwithin{table}{section}
    \renewcommand{\thetable}{\Alph{section}-\arabic{table}}

    \eightbp
}

\let\@afterindenttrue\@afterindentfalse
\@afterindentfalse

\def\enumerate{\ifnum \@enumdepth >3 \@toodeep\else
      \advance\@enumdepth \@ne
      \edef\@enumctr{enum\romannumeral\the\@enumdepth}\list
      {\csname label\@enumctr\endcsname}{\usecounter
        {\@enumctr}\itemsep 0pt\parsep 0pt
         \def\makelabel##1{\hss\llap{##1}}}\fi}

\let\endenumerate =\endlist

\def\itemize{\ifnum \@itemdepth >3 \@toodeep\else \advance\@itemdepth \@ne
\edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
\list{\csname\@itemitem\endcsname}{\itemsep 0pt\parsep 0pt
\def\makelabel##1{\hss\llap{##1}}}\fi}

\let\enditemize =\endlist

%% caption setup
\RequirePackage[format=hang]{caption}
\DeclareCaptionLabelSeparator{emsartperiod}{\hspace*{0.5em}}
\DeclareCaptionFont{capfont}{\eightbp}
\captionsetup{%
    font={capfont},
    labelfont={bf},
    labelsep=emsartperiod,
    singlelinecheck=false,
    %justification=centering,%
}
%\captionsetup[figure]{}
\captionsetup[table]{%
  position=top,%
  skip=2pt,%
  }

\DeclareCaptionFont{algofont}{\ninebp}
\DeclareCaptionLabelSeparator{algoperiod}{\hspace*{1em}}
\captionsetup[algorithm]{%
    font={algofont},
    labelsep=algoperiod,
}

\def\@begintheorem#1#2[#3]{%
  \deferred@thm@head{\the\thm@headfont \thm@indent
    \@ifempty{#1}{\let\thmname\@gobble}{\let\thmname\@iden}%
    \@ifempty{#2}{\let\thmnumber\@gobble}{\let\thmnumber\@iden}%
    \@ifempty{#3}{\let\thmnote\@gobble}{\let\thmnote\@iden}%
    \thm@swap\swappedhead\thmhead{#1}{#2\the\thm@headpunct}{#3}%
    %\the\thm@headpunct
    \thmheadnl % possibly a newline.
    \hskip\thm@headsep
  }%
  \ignorespaces}

\def\thmhead@plain#1#2#3{%
  \thmname{#1}\thmnumber{\@ifnotempty{#1}{ }{#2}}%
  \thmnote{ {\the\thm@notefont #3. }}}

\newcommand{\acknowledgements}[1]{ %{\emsartsf\textit{Acknowledgements:}} 
    \section*{Acknowledgements}
    #1}

\newenvironment{acks}[1]%
{\subsection*{\normalsize\emsartsf\bfseries Acknowledgements}\begin{refsize}\noindent #1}%
{\end{refsize}}

\newenvironment{funding}[1]%
{\subsection*{\normalsize\emsartsf\bfseries Funding}\begin{refsize}\noindent #1}%
{\end{refsize}}

\newenvironment{sm}[1]%
{\subsection*{\normalsize\emsartsf\bfseries Supplemental material}\begin{refsize}\noindent #1}%
{\end{refsize}}
 
\newenvironment{dci}[1]%
{\subsection*{\normalsize\emsartsf\bfseries Declaration of conflicting interests}\begin{refsize}\noindent #1}%
{\end{refsize}} 

\newenvironment{biog}[1]%
{\subsection*{\normalsize\emsartsf\bfseries Author biography}\begin{refsize}\noindent #1}%
{\end{refsize}}

\newenvironment{biogs}[1]%
{\subsection*{\normalsize\emsartsf\bfseries Author Biographies}\begin{refsize}\noindent #1}%
{\end{refsize}}

%% new table
\newenvironment{Table}[1][htbp]{%
    \begin{table}[#1]
        \eightbp
}{
    \end{table}
}

\newenvironment{Table*}[1][htbp]{%
    \begin{table*}[#1]
        \eightbp
}{
    \end{table*}
}

%% new algorithm
\newenvironment{Algorithm}[1][htbp]{%
    \begin{algorithm}[#1]
        \ninebp
}{
    \end{algorithm}
}
%%=======================
%\RequirePackage{array}
%% Author info
\RequirePackage{wrapfig}

\newcommand{\authorinfomation}[2]{%
    \refsize
    \vspace*{1.5em}
    \noindent%
    \textbf{#1}~ #2
}

\newcommand{\authorinfo}[4]{%
    \refsize
    \noindent
    \begin{minipage}[t]{\linewidth}
    \vspace*{1em}
    \begin{wrapfigure}[12]{l}[0em]{0.3\linewidth}
        %\fbox{
          \includegraphics[width=\linewidth]{#1} 
        %}
    \end{wrapfigure}%
    \noindent\vspace*{0em}~\\%
    {\bfseries #2}\hspace*{0.8em}#3 (Email: #4)
  \end{minipage}
}

%Endnotes
\def\enotesize{\refsize}

\def\enoteheading{\subsection*{\normalsize\bfseries\notesname}%
  \mbox{}\par\vskip-\baselineskip}

%\renewcommand\makeenmark{\theenmark.\hspace{0.75em}}

\renewcommand{\enoteformat}{%
   \rightskip\z@ \leftskip15pt \parindent=0pt
   \leavevmode{\makebox[0cm][r]{%
   \hbox to15pt{\@theenmark.\hfill}}}}
 
  
\newtheoremstyle{emsart}
{6pt plus 2pt minus 2pt}% space above
{6pt plus 2pt minus 2pt}% space below
{}% Body font
{}% Indent amount
{\bfseries}% Theorem head font
{}% Punctuation after theorem head
{0.75em}% Space after theorem head
{}% Theorem head spec

\theoremstyle{emsart}

\renewenvironment{proof}[1][\proofname]{\par
  %AS\pushQED{\qed}%
  \normalfont \topsep6\p@\@plus6\p@\relax
  \trivlist
  \item[\hskip\labelsep
        \bfseries
    #1\@addpunct{}]\ignorespaces
}{%
  %AS\popQED
  \endtrivlist\@endpefalse
}

%% refs
%\usepackage{cite}
\usepackage[numbers, %super,
    sort&compress,
    square,
    comma,%
    ]{natbib}
\renewcommand{\bibnumfmt}[1]{[#1]}
\setlength{\bibsep}{0.2em}
\renewcommand{\bibfont}{\refsize}

\renewcommand\refname{{References}}

\let\org@appendix=\appendix
\renewcommand{\appendix}{%
    \org@appendix
    \eightbp
    \renewcommand{\baselinestretch}{0.9}
}

\AtEndDocument{%
\label{LastPage}}

\pagestyle{emsartpage}

\twocolumn

%\normalsize
\tenbp
\sloppy
